package com.example.myapplication.activity;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.myapplication.R;
import com.example.myapplication.old.adapter.GameAdapter;
import com.example.myapplication.old.entity.Game;

import java.util.ArrayList;
import java.util.List;

public class SoftwareFragment extends Fragment {
    private RecyclerView recyclerView;
    private View view;
    private List<Game>list = new ArrayList<>();
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        view =inflater.inflate(R.layout.fragment_game,container,false);
        initRecyclerView();

        return view;
    }
    private void initData(){
        for(int i=0;i<10;i++){
            Game game = new Game();
            game.setNumber(i+1);
            game.setImg(R.drawable.a1);
            game.setName("拼多多"+i);
            game.setSize(i+1+"Gb");
            game.setCount(i+1+"亿次安装");
            list.add(game);
        }
    }
    private void initRecyclerView(){
        recyclerView = view.findViewById(R.id.recycler_view_hotsong);
        RecyclerView.LayoutManager manager = new LinearLayoutManager(getContext());
        recyclerView.setLayoutManager(manager);
        GameAdapter adapter = new GameAdapter();
        recyclerView.setAdapter(adapter);
        initData();
        adapter.setData(list);

    }
}
